package models

import (
	"gopkg.in/redis.v5"
	. "gini2p/config"
	"gini2p/logger"
	"fmt"
)

var RedisClients *redis.Client

func InitRedis() error {
	RedisClients = redis.NewClient(&redis.Options{
		Addr:     RedisConfig.Addr,
		Password: "", // no password set
		PoolSize: 8,
	})
	_, err := RedisClients.Ping().Result()
	if err != nil {
		logger.Warn("app", fmt.Sprint("redis连接失败:", err))
	} else {
		logger.Info("app",fmt.Sprint("redis连接成功"))
	}
	return nil
}
